package cn.szzsi.common.model;

import cn.szzsi.common.model.base.BaseWeixinMenu;

import java.util.List;

/**
 * Created by haotian on 2016/8/31.
 */
//@TableBind(tableName = "b_weixin_menu",pkName = "id")
public class WeixinMenu extends BaseWeixinMenu<WeixinMenu> {
    public static final WeixinMenu dao = new WeixinMenu().dao();


    public static final void saveMenu(String id, String uid, Integer sortNo, String name, String keyWord, Integer used, String parentId){
        WeixinMenu businessWeixinMenu=new WeixinMenu();
        businessWeixinMenu.set("id",id);
        businessWeixinMenu.set("uid",uid);
        businessWeixinMenu.set("sortno",sortNo);
        businessWeixinMenu.set("main_menu",name);
        businessWeixinMenu.set("keyword_or_url",keyWord);
        if(used==null){
            used=0;
        }
        businessWeixinMenu.set("isonuse",used);
        businessWeixinMenu.set("pid",parentId);
        businessWeixinMenu.save();
    }


    public static final List<WeixinMenu> getByUid(String uid){
        return dao.find("select * from mall_weixin_menu where uid=? order by sortno",uid);
    }

    public static final List<WeixinMenu> getPmenuList(String uid){
        return dao.find("select * from mall_weixin_menu where isonuse='1' and pid='0' and uid=? order by sortno",uid);
    }

    public static final List<WeixinMenu> getZmenuList(String uid, String pid){
        return dao.find("select * from mall_weixin_menu where isonuse='1' and uid=? and pid=? order by sortno",uid,pid);
    }
}
